package com.hanamaki.unit.testng.work;

/**
 * 三角形
 * 两边之和大于第三边
 */
public class Triangle {

    private double a;
    private double b;
    private double c;

    /**
     * 判断能否构成三角形
     * @param a
     * @param b
     * @param c
     * @return
     */
    public boolean isTriangle(double a, double b, double c) {
        if (a + b > c && a + c > b && b + c > a) {
            this.a = a;
            this.b = b;
            this.c = c;
            return true;
        } else {
            return false;
        }
    }

    /**
     * 计算周长
     * @return
     */
    public double perimeter() {
        return a + b + c;
    }

    /**
     * 计算面积
     * @return
     */
    public double area() {
        double perimeter = a + b + c;
        return Math.sqrt(perimeter * (perimeter - a) * (perimeter - b) * (perimeter - c));
    }



}
